package com.example.wasaimovie.Model.support;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
public class ResponseResult<T> implements Serializable {
    private Integer code; // 返回状态码
    private boolean success; // 是否返回成功
    private String msg; // 返回的消息
    private T data = null; // 返回的数据

    // 不带任何东西的返回数据
    public ResponseResult(){
        this.code = 200;
        this.success = true;
        this.msg = null;
        this.data = null;
    }

    // 不带msg返回数据
    public ResponseResult(T data){
        this.code = 200;
        this.success = true;
        this.data = data;
        this.msg = null;
    }

    // 附带data、msg的返回数据
    public ResponseResult(String msg, T data){
        this.code = 200;
        this.success = true;
        this.data = data;
        this.msg = msg;
    }

    // 请求失败
    public ResponseResult(Integer code, String msg){
        this.code = code;
        this.msg = msg;
        this.success = false;
        this.data = null;
    }
}
